const foo = async function () {
    await foo1();
    await foo2();
    setTimeout(() => {
        console.log("end");
    }, 1000);
};

const foo1 = function () {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            console.log("1");
            resolve();
        }, 1000);
    });
};

const foo2 = function () {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            console.log("2");
            resolve();
        }, 1000);
    });
};

foo();
